package com.tedu.api.d2_string.work;
/*
4.以下代码
 Point{
  private int x;
  private int y;
  //get,set
 }
 重写equals()代码使坐标x,y相同时,两个对象相同,
 并输出对象字符串描述(重写toString())
 */
public class T1 {
    public static void main(String[] args){
        P p1=new P(1,2);
        P p2=new P(1,2);
        System.out.println(p1.equals(p2));
    }
}
class P{
    private int x;
    private int y;
    public P(int x, int y) {
        this.x = x;
        this.y = y;
    }
    public boolean equals(Object o){
        if(o==this){
            return true;
        }
        if(o==null){
            return false;
        }
        if(this.getClass()!=o.getClass()){
            return false;
        }
        P p=(P)o;
        if(p.x==this.x||p.y==this.y){
            return true;
        }
        return false;
    }
}
